<template>
  <div class="pd30 produceFactory">
    <div class="panelWrap">
      <div class="title flex flexac flexjcsb fs14 cfff fwb pl p-r-20">
        <div>隐患排查</div>
        <!-- <el-button class="addBtn fw defaultbtn"  type="primary">添加</el-button> -->
      </div>
      <div class="con">
        <div class="con-row flex flexac pl search-box">
          <div class="groupbtn flex">
            <el-input clearable v-model="queryParam.rescueCode" class="query-input m-r-15" placeholder="救援代码" />
            <el-input clearable v-model="queryParam.registerCode" class="query-input m-r-15" placeholder="电梯注册代码" />
            <el-button @click="getSystemList()" type="primary">查询</el-button>
          </div>
        </div>
        <el-table id="dataList" ref="dataList" class="con-table" type="expand" :data="dataList.slice((paging.currentPage - 1) * paging.pageSize, paging.currentPage * paging.pageSize)" @select="handleCheck" @select-all="handleCheck" @selection-change="handleCheckChange">

          <el-table-column width="50" type="selection" label="全选" />

          <el-table-column align="center" label="救援代码">
            <template slot-scope="scope">
              <span>{{ scope.row.rescueCode }}</span>
            </template>
          </el-table-column>

          <el-table-column align="center" label="注册代码">
            <template slot-scope="scope">
              <span>{{ scope.row.registerCode }}</span>
            </template>
          </el-table-column>

          <el-table-column align="center" label="使用场所">
            <template slot-scope="scope">
              <span>{{ scope.row.usePlaceName }}</span>
            </template>
          </el-table-column>

          <el-table-column align="center" label="使用单位">
            <template slot-scope="scope">
              <span>{{ scope.row.useUnitName }}</span>
            </template>
          </el-table-column>

          <el-table-column align="center" label="安装地址">
            <template slot-scope="scope">
              <span>{{ scope.row.installAddress }}</span>
            </template>
          </el-table-column>

          <el-table-column prop="name" align="center" label="操作">
            <template slot-scope="scope">
              <el-button class="defaultbtn" type="primary" @click="handleEdit(scope.$index, scope.row)">
                <i class="el-icon-search" /> 排查结果</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination class="paginationWrap flex" :current-page="paging.currentPage" :page-sizes="paging.pageSizeArr" :page-size="paging.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="paging.total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
      </div>
    </div>
    <resultDialog v-model="visible" @handleCloseDialog="closeDialog" />
  </div>
</template>

<script>
import { elevatorQueryList, realtimeDetailList } from '@/api/elevator/elevator'
import { showNotice, formatDateTime } from '@/utils/toolclass'
import resultDialog from './dialog'
export default {
  components: { resultDialog },
  name: 'dangerInvestigate',
  props: {},
  data() {
    return {
      paging: {
        currentPage: 1,
        pageSize: 10,
        pageSizeArr: [10, 20, 50, 100],
        total: 400
      },
      visible: false,
      dataList: [],
      queryParam: {

      },
    }
  },
  computed: {},
  watch: {},
  created() {
    this.getSystemList();
  },
  mounted() {
    this.$storage.set('upUrl', JSON.stringify({ 'path': '/routineMaintenan/dangerInvestigate/index' }))
  },
  methods: {
    handleEdit() {
      this.visible = true
    },
    closeDialog(){
      this.visible = false
    },
    handleCheck(selection, row) {
      this.$refs.dataList.clearSelection()
      if (selection.length === 0) { // 判断selection是否有值存在
        return
      }
      if (row) {
        this.selectioned = row
        this.row = row
        this.delPro = row
        this.$refs.dataList.toggleRowSelection(row, true)
      }
    },
    handleCheckChange(row) {
      if (row.length === 0) {
        this.selectioned = null
      }
    },
    getSystemList() {
      const params = ['', '', '', this.paging.currentPage, this.paging.pageSize, this.queryParam.registerCode, '', this.queryParam.rescueCode, '']
      elevatorQueryList(...params).then((res) => {
        if (res.code === '000000') {
          const i = res.data.map((item, i) => i)
          const ids = res.data.map((item, i) => item.id).join(',')
          this.dataList = res.data;
          this.paging.total = i.length
        }
      })
    },
    handleSizeChange(val) {
      this.paging.pageSize = val
      this.getSystemList()
    },
    handleCurrentChange(val) {
      this.paging.currentPage = val
      this.getSystemList()
    }
  }
}
</script>
<style lang="scss">
@import "@/styles/public.scss";
.e-list {
  padding: 15px 10px;
  font-size: 14px;
  flex-wrap: wrap;
  .e-main {
    position: relative;
    .status-list {
      position: absolute;
      top: 5px;
      left: 0;
      right: 0;
      z-index: 99;
      padding: 0 10%;
      > * {
        margin-right: 15px;
      }
      .floor {
        padding: 5px 10px;
      }
    }
  }

  .e-item {
    width: 25%;
    text-align: center;
    padding: 15px 30px;
  }
}
.errorImg {
  display: inline-block;
  width: 60px;
  height: 60px;
}
.sys-input {
  width: 260px;
}
.icon-qingkong:before {
  margin-right: 4px;
}
</style>


